import { Client } from "grpc";
import { BackendStore, BackendServices, Stages, StringIndexer } from "mmb";
import { MicroCache } from "mmb";

export interface MicroServiceConf {
  grpc: string | null;
  api: string | null;
  vars: StringIndexer | undefined;
}

// 代表一个microservice,如bgs,mgm
export interface GrpcService {
  [k: string]: Client | null;
}

interface BgApiStore extends BackendStore {
  confs: {
    [k: string]: MicroServiceConf;
  };
  envs: {
    stage: Stages;
  };
  grpcServices: {
    [k: string]: GrpcService;
  };
  mq: {
    nsq: {
      lookupd: string | null;
      nsqd: string | null;
    };
  };
  redis: {
    address: string | null;
    password: string | null;
  };
}

const _store: BgApiStore = {
  app: BackendServices.BGAPI,
  cache: MicroCache.create(),
  confs: {
    // [BackendServices.BGS]: {
    //   grpc: null,
    //   api: null
    // }
  },
  envs: {
    stage: Stages.TEST,
  },
  grpcServices: {
    // [BackendServices.BGS]: {
    // }
  },
  mq: {
    nsq: {
      lookupd: null,
      nsqd: null,
    },
  },
  redis: {
    address: null,
    password: null,
  },
};

export default _store;
